﻿<%@ Page Language="C#" MasterPageFile="~/Masters/Basic.Master" AutoEventWireup="true" CodeBehind="DeliveryList.aspx.cs" Inherits="PMS.UI.CM.DeliveryList" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        $(function () {
            var height = $("#divTotal").height();
            var master = $("#master").height();
            var content = parseFloat(height) - parseFloat(master) - 30;
            $("#tbList").css("height", content);
        });
    </script>
    <script type="text/javascript">
        $(function () {
            //   $('#btnModify').linkbutton('disable');
            $("#tbList").datagrid({
                url: '/Logic/CM/BottleDeliveryAjax.aspx?method=GetDeliveryList',
                loadMsg: '数据加载中请稍后……',
                fitColumns: false,
                pagination: true,
                queryParams: com.serializeSearchArray("form1"),
                rownumbers: true,
                idField: "ID",
                singleSelect: true,
                pageSize: 20,
                pageList: [20, 50, 100],
                striped: true,
                frozenColumns: [[{ field: 'ck', checkbox: true, width: 30 },
                 { field: 'ID', title: 'ID', align: "center", width: 40 },
                  { field: 'Code', title: '发货单号 ', align: "center", width: 100 },
                 { field: 'ProductOrderCode', title: '生产订单号 ', align: "center", width: 100 },
                 { field: 'ContractCode', title: '合同编号', align: "center", width: 100 },
                 { field: 'CustomerName', title: '客户单位名称', align: "center", width: 100 },
                ]],
                columns: [[
                 { field: 'DeliveryDate', title: '发货日期', align: "center", width: 120 },
                 { field: 'DeliveryNum', title: '发货数量', align: "center", width: 60 },
                  { field: 'OldBottleNum', title: '旧瓶数量', align: "center", width: 60 },
                   { field: 'NewBottleNum', title: '新瓶数量', align: "center", width: 60 },
                 {
                     field: 'EMSCode', title: '物流单号', align: "center", width: 100, editor: {
                         type: "validatebox",
                         options: {}
                     }
                 },
                 {
                     field: 'CarCode', title: '车号', align: "center", width: 100, editor: {
                         type: "validatebox",
                         options: {}
                     }
                 },
                 { field: 'FillPersonName', title: '收发员', align: "center", width: 60 },
                 {
                     field: 'DeliveryPerson', title: '送货人', align: "center", width: 60, editor: {
                         type: "validatebox",
                         options: {}
                     }
                 },
                { field: 'ReceiveAddress', title: '送货地址', align: "center", width: 100 },
                { field: 'InvoiceAddress', title: '收发票地址', align: "center", width: 100 },
                {
                    field: 'Note', title: '备注', align: "center", width: 100, editor: {
                        type: "validatebox",
                        options: {}
                    }
                }
                ]],
                onAfterEdit: function (rowIndex, rowData, changes) {
                    if (editAction == "edit") {
                        com.ajax({
                            url: '/Logic/CM/BottleDeliveryAjax.aspx?method=EditDelivery&id=' + rowData.ID,
                            data: rowData,
                            success: function (data) {
                                com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); });
                            }
                        });
                    }
                    editRow = undefined;
                },
                onCancelEdit: function (rowIndex, rowData) {
                    $("#tbList").datagrid("rejectChanges");
                },
                onDblClickRow: function (rowIndex, rowData) {
                    top.wrapper.addTab("气瓶发货细则", "/UI/CM/BottleDeliveryDetail.aspx?action=view&ID=" + rowData.ID)
                },
                onLoadSuccess: function (data) {

                }
            });

        });

    </script>

    <script type="text/javascript">
        editRow = undefined;
        editAction = undefined;

        //编辑
        function funcEdit() {
            var row = $('#tbList').datagrid('getSelected');

            if (row) {
                if (editRow != undefined) {
                }
                else {
                    var index = $("#tbList").datagrid('getRowIndex', row);
                    $("#tbList").datagrid('beginEdit', index);
                    editAction = "edit";
                    editRow = index;
                    rowData = $("#tbList").datagrid("getSelected");
                }
            }
            else {
                com.message("information", "请选中一行");
            }
        }

        //查询
        function funcSearch() {
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);
        }

        //删除
        function funcRemove() {
            $.messager.confirm('确认对话框', '您确定删除该发货记录吗？', function (r) {
                if (r) {
                    
                    var row = $('#tbList').datagrid('getSelected');
                    if (row) {
                        com.ajax({
                            url: "/Logic/CM/BottleDeliveryAjax.aspx?method=DelDelivery&id=" + row.ID,
                            success: function (data) {
                                com.message(data.state, data.msg, function () {
                                    $("#tbList").datagrid("reload");
                                    $('#tbList').datagrid('clearSelections');
                                })
                            }
                        });
                    }
                    else {
                        com.message("information", "请选中一行");
                    }
                }
            });
            editRow = undefined;
            editAction = undefined;
        }

        //取消编辑
        function funcCancel() {
            $('#tbList').datagrid("cancelEdit", editRow);
            editRow = undefined;
            editAction = undefined;
        }

        //保存
        function funcSave() {
            $('#tbList').datagrid('endEdit', editRow);
        }

        //重置
        function funcReload() {
            $("#form1").form("reset");
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);
            editRow = undefined;
            editAction = undefined;
        }

        //打印发货单
        function funcPrintDelivery() {
            
            var row = $("#tbList").datagrid("getSelected");
            if (row) {
                top.wrapper.addTab("打印发货单", "/UI/CM/PrintDelivery.aspx?Id=" + row.ID);
            } else {
                com.message("information", "请选中一行");
            }
        }
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="divTotal" style="height: 100%; width: 100%">

        <div id="master" class="container_16" style="height: auto">
            <form id="form1">
                <div class="grid_2 sealbl" style="width: 100px">
                    发货单号 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="Code" name="Code" data-cp="co" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    客户名称 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" class="easyui-combobox" id="CustomerName" name="CustomerName" data-cp="=" data-options="valueField:'text',textField:'text',url:'/Logic/BD/CompanyAjax.aspx?method=GetAllCompanyNameList',panelHeight:'auto'" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    生产订单号 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="ProductOrderCode" name="ProductOrderCode" data-cp="co" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    合同编号 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="ContractCode" name="ContractCode" data-cp="co" />
                </div>
                <div class="Clear"></div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    物流单号 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="EMSCode" name="EMSCode" data-cp="co" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    车号 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="CarCode" name="CarCode" data-cp="co" />
                </div>
                <div class="grid_2 sealbl" style="width: 100px">
                    发货日期从:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="startDeliveryDate" name="startDeliveryDate" data-cp="str>=" class="easyui-datebox" />
                </div>
                <div class="grid_2 sealbl">
                    到:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="endDeliveryDate" name="endDeliveryDate" data-cp="str<=" class="easyui-datebox" />
                </div>

            </form>
        </div>
        <table id="tbList" title="发货记录表 " style="width: 100%">
        </table>
    </div>
</asp:Content>

